<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>商城产品页面</title>
    <link rel="stylesheet" type="text/css" href="${basePath }/public/css/common.css">
    <script type="text/javascript" src="${basePath}/public/js/jquery.min.js"></script>
    <script type="text/javascript">
        function add() {
            var goodsId = $("#goodId").val();
            $.ajax({
                url:"${basePath}/home/cart",
                type:"post",
                data:{
                    goodsId:goodsId
                },
                success:function (result) {
                    if (result.status==1){
                        window.location.href="${basePath}/home/cart"
                    }else {
                        alert("添加失败")
                    }
                }

            })
        }

        function select() {
            var name = $("#a").val();
            window.location.href="${basePath}/home/homepage/like?name="+name;
        }

    </script>
</head>
<body>
<div class="top-header">
    <div class="section">
        <div class="top-header-left f-left">
            <a href="#">LOGO</a>
        </div>
        <div class="top-header-right f-right">
            <c:choose>
                <c:when test="${empty user}">
                    <a href="${basePath}/home/vipUser/toLogin">登录</a>
                    <a href="${basePath}/home/vipUser/toRegisterVip">注册</a>
                    <a href="${basePath}/admin/adminUser/toLogin">后台</a>
                </c:when>
                <c:otherwise>
                    <a href="#">欢迎你!<W style="color: bisque;font-weight: bold; font-family: 微软雅黑; font-size: 20px;">${user.username}</W></a>
                    <a href="${basePath}/admin/adminUser/toLogin">后台</a>
                    <a href="${basePath}/home/vipUser/write">注销</a>
                </c:otherwise>
            </c:choose>
        </div>
    </div>
</div>

<div class="section nav-header">
    <ul class="nav-menus f-left">
        <li><a href="${basePath}/home/homepage/index">首页</a></li>
        <li ><a href="${basePath}/home/homepage/toProductList" class="active">产品列表</a></li>
        <li><a href="${basePath}/home/cart">购物车</a></li>
        <li><a href="${basePath}/home/vipUser/index" >会员中心</a></li>
        <li><a href="${basePath}/home/News/toNews">新闻资讯</a></li>
        <li><a href="${basePath}/home/pay/contact">联系我们</a></li>
    </ul>
    <div class="f-right nav-right">
        <input type="text" class="seacher-input f-left" placeholder="输入关键字">
        <a class="seacher-but  f-left" onclick="select()">搜索</a>
    </div>
</div>

<c:forEach items="${list}" var="m">
<div class="section">
<input type="hidden" id="goodId" value="${m.id}">
    <div class="wrapper clearfix">
        <div class="wrap-box">
                <div class="goods-box clearfix">
                    <!--商品图片-->
                    <div class="goods-pic">
                        <!--幻灯片-->
                        <div class="pic-box">
                            <div class="pic-preview">
                                <span class="jqzoom">
                                    <img  src="${basePath}/public/images${m.goodsImg}" alt="">
                                </span>
                            </div>
                        </div>
                        <!--/幻灯片-->
                    </div>
                    <!--/商品图片-->

                    <!--商品信息-->
                    <div class="goods-spec">
                        <h1>${m.goodsName}</h1>
                        <p class="subtitle">欢迎比价后购买</p>
                        <div class="spec-box">
                            <dl>
                                <dt>货号</dt>
                                <dd id="commodityGoodsNo">${m.goodsSn}</dd>
                            </dl>
                            <dl>
                                <dt>市场价</dt>
                                <dd><s id="commodityMarketPrice">${m.marketPrice}</s></dd>
                            </dl>
                            <dl>
                                <dt>销售价</dt>
                                <dd><em class="price" id="commoditySellPrice">${m.sellPrice}</em></dd>
                            </dl>
                        </div>

                        <div class="spec-box">
                            <dl>
                                <dt>购买数量</dt>
                                <dd>
                                    <div class="stock-box" style="line-height: 30px;">
                                       <strong>${m.isOnSale}</strong>
                                    </div>
                                    <span class="stock-txt">
                                        库存<em id="commodityStockNum">${m.goodsNumber}</em>件
                                    </span>
                                </dd>
                            </dl>
                            <dl>
                                <dd>
                                    <div class="btn-buy" id="buyButton">
                                        <button class="buy" onclick="javascript:window.location.href='${basePath}/home/homepage/toWriteorder?id=${m.id}'">立即购买</button>
                                        <button class="add" id="add" onclick="add()">加入购物车</button>
                                    </div>
                                </dd>
                            </dl>
                        </div>


                    </div>
                    <!--/商品信息-->
                </div>

        </div>
    </div>

    <div id="goodsTabs" class="goods-tab bg-wrap">
        <!--选项卡-->
        <div id="tabHead" class="tab-head">
            <ul>
                <li>
                    <a class="selected" href="javascript:;">商品介绍</a>
                </li>

            </ul>
        </div>
        <!--/选项卡-->

        <!--选项内容-->
        <div class="tab-content entry" style="display:block;">
            ${m.description}
        </div>
    </div>

</div>
</c:forEach>


<div class="section qitian-main">
    <img src="${basePath}/public/images/qitian.png">
</div>

<div class="footer-copyright">
    <p>软信商城©2013-2017 软信大学版权所有 京ICP备17017089号 京公网安备11000002000006号</p>
</div>

</body>

</html>